package com.xxx.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.blog.entity.TbUser;
import com.xxx.blog.mapper.TbUserMapper;
import com.xxx.blog.service.TbUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author WangXJ
 * @since 2021-08-07
 */
@Service
public class TbUserServiceImpl extends ServiceImpl<TbUserMapper, TbUser> implements TbUserService {

    @Autowired
    TbUserMapper tbUserMapper;

    @Override
    public TbUser haveUser(String username, String password) {
        QueryWrapper<TbUser> wrapper = new QueryWrapper<>();
        wrapper.eq("userName",username);
        wrapper.eq("userPwd",password);
        return tbUserMapper.selectOne(wrapper);
    }

    @Override
    public int registerUser(String username, String password) {
        TbUser user = new TbUser();
        user.setUsername(username);
        user.setUserpwd(password);
        user.setUseriden("com");
        return tbUserMapper.insert(user);

    }
}
